﻿using System;
using ZyGames.DZPocker.Model;
using ZyGames.Framework.Common;
using ZyGames.Framework.Common.Log;
using ZyGames.Framework.Game.Cache;

namespace ZyGames.DZPocker.Bll.Logic
{
	/// <summary>
	/// 游戏大厅
	/// </summary>
	public class GameHall
	{
		private GameUser _user;

		/// <summary>
		/// 游戏大厅
		/// </summary>
		/// <param name="user"></param>
		public GameHall(GameUser user)
		{
			_user = user;
		}

		/// <summary>
		/// 修改头像
		/// </summary>
		/// <param name="headIcon"></param>
		/// <returns></returns>
		public bool ChangeUserHead(string headIcon)
		{
			if (_user == null)
				return false;
			_user.HeadIcon = headIcon;
			var cacheSet = new GameDataCacheSet<GameUser>();
			cacheSet.Update();
			return true;
		}

		/// <summary>
		/// 获取称号
		/// </summary>
		/// <returns></returns>
		public string GetTitle()
		{
			if (_user == null)
				return "";
			var title = new ConfigCacheSet<TitleInfo>().FindKey(_user.TitleId);
			return title != null ? title.Name : "";
		}
	}
}
